package com.lin.processor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;

public class MyPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("MyPostProcessor的PostProcessBeanFactory");
        // 注册BeanDefinition
        /*RootBeanDefinition beanDefinition = new RootBeanDefinition();
        beanDefinition.setBeanClassName("com.lin.dao.Impl.PersonDaoImpl");
        // 强转为DefaultListableBeanFactory
        DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;
        // 注册BeanDefinition
        defaultListableBeanFactory.registerBeanDefinition("personDao", beanDefinition);*/

        // 并修改Bean的全限定名
        /*BeanDefinition beanDefinition = beanFactory.getBeanDefinition("userService1");
        beanDefinition.setBeanClassName("com.lin.dao.Impl.UserDaoImpl");*/

    }
}
